home *** CD-ROM | disk | FTP | other *** search
/ SGI Enlighten DSM 1.1 / SGI EnlightenDSM 1.1.iso / ntsetup / disk2 / _setup.2 / Group11 / restartprocess.sh next >
Linux/UNIX/POSIX Shell Script  |  1998-06-30  |  3KB  |  75 lines

  1. #!/bin/sh
  2. #
  3. # Copyright (c) 1990-1998 Enlighten Software Solutions, Inc.
  4. #
  5. # Example shell script to restart a process when Events notices
  6. # the number of instances has fallen below the Low Threshold.
  7. # Process tests are always performed every 30 seconds.
  8. # This script will start one new copy of the process every 30
  9. # seconds until the total count exceeds the low threshold
  10. # (assuming the named process can be started, and they keep running).
  11. #
  12. # This script is a generic example only, it is not intended to handle
  13. # all situations and may need some customization.  See below where
  14. # the enivronment variables are set.
  15. # THIS IS UNSUPPORTED SOFTWARE, NO WARRANTY EXPRESS OR IMPLIED.
  16. #
  17. # Dec 1996, Ron Hitchens, Enlighten Software Solutions
  18. #
  19. #
  20. # A command run by an AgentMon process instances event will be called like:
  21. #    <commandname> "<processname> instances" <count> processes <type> <date>
  22. #    
  23. # Where
  24. #    <commandname>    = The path of the command to run (this file).
  25. #    "<processname> instances"
  26. #            = The test name.  These two words will constitute
  27. #              one argument.  <processname> will be the name of
  28. #              the process you are monitoring.  The subname
  29. #              "instances" indicates you're measuring occurances,
  30. #              of the process.  This will be "size" for size
  31. #              tests, etc.  The "'s are not part of the argument.
  32. #    <count>        = The value of the test (the current number of
  33. #              process with the name <processname>).
  34. #    processes    = The literal string "processes".  Generically this
  35. #              is the test units name.
  36. #    <type>        = The threshold type.  This will be "low" if the
  37. #              low threshold trips, "high" for the high threshold
  38. #              and "ok" when returning to normal from an alarm.
  39. #    <date>        = The last argument is the time of the event, in
  40. #              unix date(1) format.  Note that there are spaces
  41. #              in imbedded in this argument.
  42.  
  43. type=$4        # set to event type passed in arg 4
  44. set $1        # convert the compound argument to positional arguments
  45. cmd=$1        # get the first piece <processname>
  46.  
  47. # Set this path to those you want to search for <processname>
  48. # Commands are run by AgentMon, which is a daemon running as root
  49. # with a minimal path.  Commands ARE NOT run in the GUI context.
  50.  
  51. PATH=/usr/local/bin:/usr/bin:/bin:/usr/openwin/bin:/usr/X11/bin:/usr/bin/X11
  52. export PATH
  53.  
  54. # This will tell any X-Windows apps to run on the local host.  Even though
  55. # the GUI is running under X, events commands are run by AgentMon which
  56. # is not under the X environment.
  57. # BEWARE: If you're creating process instance tests on a host other than
  58. # the one running the GUI, this can cause windows to pop up on those
  59. # remote displays, not where you're running the GUI.
  60.  
  61. DISPLAY=unix:0        # run on localhost
  62. export DISPLAY
  63.  
  64. # if the alarm is a low threshold trigger, create another instance
  65.  
  66. if [ $type = "low" ] ; then
  67.     exec $cmd
  68. fi
  69.  
  70. # you can check for "ok", "high", etc and do other things if you like
  71.  
  72. exit 0
  73.  
  74.